home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------------
- -- Weapon Armageddon + Projectile Comet
- -- Original Carnage Contest Weapon
- -- Script by DC, August 2009, www.UnrealSoftware.de
- --------------------------------------------------------------------------------
-
- -- Setup Tables
- if cc==nil then cc={} end
- cc.armageddon={}
- cc.armageddon.comet={}
-
- -- Load & Prepare Ressources
- cc.armageddon.gfx_icon=loadgfx("weapons/armageddonicon.png") -- Weapon Icon
- setmidhandle(cc.armageddon.gfx_icon)
- cc.armageddon.gfx_pro=loadgfx("weapons/comet.bmp") -- Projectile Image
- setmidhandle(cc.armageddon.gfx_pro)
- cc.armageddon.sfx_waterimpact=loadsfx("firefragment.wav")
-
- --------------------------------------------------------------------------------
- -- Weapon: Armageddon
- --------------------------------------------------------------------------------
-
- cc.armageddon.id=addweapon("cc.armageddon","Armageddon",cc.armageddon.gfx_icon,0,3) -- Add Weapon (0 uses, first in round 3)
-
- function cc.armageddon.draw() -- Draw
- -- Fade Dark
- if weapon_shots>0 and weapon_timer<0.4 then
- weapon_timer=weapon_timer+0.01
- end
- end
-
- function cc.armageddon.attack(attack) -- Attack
- if (weapon_shots<=0) and (attack==1) then
- -- No more weapon switching!
- useweapon(0)
- weapon_shots=weapon_shots+1
- -- Random Seed
- randomseed(getframe()*123+getround()*98)
- -- Spawn Comets (amount depending on map size)
- limit=math.ceil(getmapwidth()/100)*math.ceil(getmapheight()/150)
- if limit>100 then
- limit=100
- end
- for i=1,limit,1 do
- pid=createprojectile(cc.armageddon.comet.id)
- projectiles[pid]={}
- projectiles[pid].x=random(40,getmapwidth()-40)
- projectiles[pid].y=-random(500,650)
- projectiles[pid].sx=random(-15,15)*0.1
- projectiles[pid].sy=random(150,200)*0.1
- projectiles[pid].timer=i*random(15,20)
- end
- -- End Turn
- endturn()
- end
- end
-
- --------------------------------------------------------------------------------
- -- Projectile: comet
- --------------------------------------------------------------------------------
-
- cc.armageddon.comet.id=addprojectile("cc.armageddon.comet") -- Add Projectile
-
- function cc.armageddon.comet.draw(id) -- Draw
- setbgcolor(0,0,0,weapon_timer,0.01)
- if projectiles[id].timer<=0 then
- -- Fire
- setblend(blend_light)
- setalpha(math.random(1,7)*0.1)
- setcolor(255,255,255)
- setscale(1,1)
- setrotation(math.deg(math.atan2(projectiles[id].sx,-projectiles[id].sy))+180)
- drawimage(gfx_fire,projectiles[id].x,projectiles[id].y)
- -- Comet
- setblend(blend_alpha)
- setalpha(1)
- setrotation(math.deg(math.atan2(projectiles[id].sx,-projectiles[id].sy)))
- drawimage(cc.armageddon.gfx_pro,projectiles[id].x,projectiles[id].y)
- end
- end
-
- function cc.armageddon.comet.update(id) -- Update
- -- Timer
- if projectiles[id].timer>0 then
- -- Count Down before comet appears
- projectiles[id].timer=projectiles[id].timer-1
- else
- -- Commet appears
- rot=math.deg(math.atan2(projectiles[id].sx,-projectiles[id].sy))
- -- Particle Tail
- particle(p_smoke,projectiles[id].x+math.random(-6,6),projectiles[id].y-7)
- particlespeed(math.random(-2,2)*0.1,math.random(-2,2)*0.1)
- particlefadealpha(0.05)
- particle(p_lightpuff,projectiles[id].x+math.random(-5,5),projectiles[id].y-5)
- particlefadealpha(0.04)
- -- Move (in substep loop for optimal collision precision)
- msubt=math.ceil(math.max(math.abs(projectiles[id].sx),math.abs(projectiles[id].sy))/10)
- msubx=projectiles[id].sx/msubt
- msuby=projectiles[id].sy/msubt
- for i=1,msubt,1 do
- projectiles[id].x=projectiles[id].x+msubx
- projectiles[id].y=projectiles[id].y+msuby
- -- Collision
- if collision(cc.armageddon.gfx_pro,projectiles[id].x,projectiles[id].y)==1 then
- -- Cause damage
- arealdamage(projectiles[id].x,projectiles[id].y,155,45)
- -- Destroy terrain
- terrainexplosion(projectiles[id].x,projectiles[id].y,60,1)
- -- Crater
- grey=math.random(0,40)
- if math.random(0,1)==1 then
- terrainalphaimage(gfx_crater175,projectiles[id].x,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
- else
- terrainalphaimage(gfx_crater200,projectiles[id].x,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
- end
- -- Free projectile
- freeprojectile(id)
- break
- end
- -- Water
- if (projectiles[id].y)>getwatery()+5 then
- -- Effects
- particle(p_waterhit,projectiles[id].x,projectiles[id].y)
- particlesize(1.5,2.0)
- playsound(cc.armageddon.sfx_waterimpact)
- -- Free projectile
- freeprojectile(id)
- break
- end
- end
- end
- end